package day02.pm;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class Demo03 {
    public static void main(String[] args) {
        JFrame jFrame = new JFrame("捕鱼");
        jFrame.setSize(800,480);
        jFrame.setResizable(false);
        jFrame.setLocationRelativeTo(null);
        //添加窗口关闭事件
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MyPanel myPanel = new MyPanel();
        jFrame.add(myPanel);
        //新版的窗口显示
        jFrame.setVisible(true);
    }
}
class MyPanel extends JPanel{
    @Override
    public void paint(Graphics g) {
        BufferedImage image = null;
        try {
            image = ImageIO.read(new File("fish/images/bg.jpg"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        g.drawImage(image,0,0,null);
    }
}
